﻿#region File Description
/****************************************************************************
*                                                                           *
* Pause Menu Screen.                                                        *
*                                                                           *
* Copyright (c) Ionescu Marius. All rights reserved(2010).                  *
*                                                                           *
****************************************************************************/
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace XNA_FRAMEWORK
{
    class XNAPauseMenuScreen : XNAMenuScreen
    {
        #region Initialization

        public XNAPauseMenuScreen()
            : base("Paused")
        {
            IsPopup = true;

            XNAMenuEntry resumeGameMenuEntry = new XNAMenuEntry("Resume Game");
            XNAMenuEntry quitGameMenuEntry = new XNAMenuEntry("Quit Game");

            resumeGameMenuEntry.Selected += OnCancel;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);
        }

        #endregion

        #region Handle Input

        void QuitGameMenuEntrySelected(object sender, XNAPlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this game?";
            XNAMessageBoxScreen confirmQuitMessageBox = new XNAMessageBoxScreen(message);
            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }

        void ConfirmQuitMessageBoxAccepted(object sender, XNAPlayerIndexEventArgs e)
        {
            XNALoadingScreen.Load(ScreenManager, false, null, new XNABackgroundScreen(),
                                                           new XNAMainMenuScreen());
        }

        #endregion

        #region Draw

        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);
            base.Draw(gameTime);
        }

        #endregion
    }
}
